<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
    <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <%@ include file="top_new.jsp"%> 
    <link rel="stylesheet" href="/css/pintuer.css">
</head>
<body>
  <div class="panel admin-panel" style="width: 100%;">
 
  <div class="padding border-bottom layui-form-item">
    <div class="layui-input-inline">
      <input type="text" name="fvalue" id = "fvalue" placeholder="标题" autocomplete="off" class="layui-input">
    </div>
    <button class="layui-btn" id ="query">查询</button>
  </div>
  <!--  -->
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  <div class="layui-tab-content" style="height: 100%;">
  <input type="hidden" name="fmzgicId" id="fmzgicId" value="${fmzgicId}">
    <div class="layui-tab-item layui-show">
    	<table class="layui-table" id="no_list">
		  <colgroup>
		    <col width="5%">
		    <col width="65%">
		    <col width="30%">
		    <col >
		  </colgroup>
		  <thead>
		    <tr>
		      <th name ="fid" id="fid">#</th>
		      <th name ="ftitle" id="ftitle">标题	</th>
		      <th name ="fctime" id="fdate">抓取时间</th>
		    </tr> 
		  </thead>
		  <tbody id = "t_tbody">
		  </tbody>
		    <tr>
		       <td colspan="2"><div id="div_page"></div></td>
		        <td id="counts"></td>
		    </tr>
		</table> 
    </div>
  </div>
</div>
</div>
<script type="text/javascript"> 
window.onload=function() {
	$.post("<%=basePath%>grid/toGridList",
		    {
				page:1,
				pagesize:10,
				fmzgicId:$("#fmzgicId").val()
		    },
		    function(res){
		    	if (res.errorCode == 0) {
		    		var data=res.data;
		    		laypage({
		    		      cont: 'div_page', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
		    		      pages: data.totalPage, //通过后台拿到的总页数
		    		      curr: data.pageNumber, //当前页
		    		      jump: function(obj, first){ //触发分页后的回调
		    		    	  $("#t_tbody").empty();
		    		    	  if(!first){
			    		    	  $.post("<%=basePath%>grid/toGridList",
			    		    			    {
			    		    					page:obj.curr,
			    		    					pagesize:10,
			    		    					fmzgicId:$("#fmzgicId").val(),
			    		    					fvalue:$("#fvalue").val()
			    		    			    },
			    		    			    function(res){
			    		    			    	var tbody ="";
		    		    			    		if (res.errorCode == 0) {
			    		    			    		 tbody = pageDataNum(res.data.list);  
		    		    			    		}
		    		    			    		$("#counts").html("总行数:"+res.data.totalRow);
		    		    			    		$("#t_tbody").append(tbody);  
			    		    			    });
		    		    	  }else{
		    		    		   var tbody ="";
		    		    		   tbody = pageDataNum(data.list);  
		    		    		   $("#counts").html("总行数:"+res.data.totalRow);
		    			    	   $("#t_tbody").append(tbody);  
		    		    	  }
		    		    	 
		    		      }
		    		});
		    	}else{
		    		if (res.errorCode == 2) {
		    			layer.alert(res.message) ;
		    		}else{
		    			layer.msg("参数错误："+res.message, {shift: 6});
		    		}
		    	}
		    }); 
};
$("#bt_add").click(function(){
	var diag = new top.Dialog();
    diag.Drag=true;
    diag.Title ="用户编辑";
    diag.URL = 'http://www.baidu.com';
    diag.Width = 400;
    diag.Height = 400;
    diag.CancelEvent = function(){ //关闭事件
        diag.close();
    };
    diag.show();
});
function refresh(){
	 $.post("<%=basePath%>grid/toGridList",
			    {
					page:1,
					pagesize:5,
					fvalue:$("#fvalue").val(),
					fmzgicId:$("#fmzgicId").val()
			    },
			    function(res){
			    	if (res.errorCode == 0) {
			    		var data=res.data;
			    		laypage({
			    		      cont: 'div_page', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
			    		      pages: data.totalPage, //通过后台拿到的总页数
			    		      curr: data.pageNumber, //当前页
			    		      jump: function(obj, first){ //触发分页后的回调
			    		    	  $("#t_tbody").empty();
			    		    	  if(!first){
				    		    	  $.post("<%=basePath%>grid/toGridList",
				    		    			    {
				    		    					page:obj.curr,
				    		    					pagesize:5,
				    		    					fmzgicId:$("#fmzgicId").val(),
				    		    					fvalue:$("#fvalue").val()
				    		    			    },
				    		    			    function(res){
				    		    			    	var tbody ="";
			    		    			    		if (res.errorCode == 0) {
				    		    			    		 tbody = pageDataNum(res.data.list);  
			    		    			    		}
			    		    			    		$("#counts").html("总行数:"+res.data.totalRow);
			    		    			    		$("#t_tbody").append(tbody);  
				    		    			    });
			    		    	  }else{
			    		    		   var tbody ="";
			    		    		   tbody = pageDataNum(data.list);  
			    		    		   $("#counts").html("总行数:"+res.data.totalRow);
			    			    	   $("#t_tbody").append(tbody);  
			    		    	  }
			    		    	 
			    		      }
			    		});
			    	}else{
			    		if (res.errorCode == 2) {
			    			layer.alert(res.message) ;
			    		}else{
			    			layer.msg("参数错误："+res.message, {shift: 6});
			    		}
			    	}
			    }); 
}
$("#query").click(function(){ 
	refresh();
})
function del(id){
	if(confirm("您确定要删除吗?")){
		$.post("<%=basePath%>grid/grid_del",
		    {
				fid:id
		    },
		    function(res){
		    	if (res.errorCode == 0) {
		    		window.location.reload();
		    	}else{
		    		if (res.errorCode == 2) {
		    			layer.alert(res.message) ;
		    		}else{
		    			layer.msg("参数错误："+res.message, {shift: 6});
		    		}
		    	}
		    }); 
	}
}

function cancle(id){
	if(confirm("确定需要取消文章审核?")){
		var index = layer.load(2, {time: 10000}); //又换了种风格，并且设定最长等待10秒 
		$.post("<%=basePath%>grid/gridCancle",
			    {
					fid:id
			    },
			    function(ret){
			    	if (ret.isOk) {
			    		layer.msg('文章已审核,查看请到审核列表', {icon: 1});
			    		window.location.reload();
			    	}else{
			    		layer.msg(ret.msg, {shift: 6});
			    	}
			    	//关闭
					layer.close(index); 
			    }); 
	}
}
function fire(id){
	if(confirm("您确定要设置为热点么(最多6个热点)?")){
		$.post("<%=basePath%>grid/grid_fire",
			    {
					fid:id
			    },
			    function(res){
			    	if (res.errorCode == 0) {
			    		window.location.reload();
			    	}else{
			    		if (res.errorCode == 2) {
			    			layer.alert(res.message) ;
			    		}else{
			    			layer.msg("参数错误："+res.message, {shift: 6});
			    		}
			    	}
			    }); 
	}
}
function prew(id){
	window.open('<%=basePath%>grid/grid_view?fid='+id); 
}
function eidt(id){
	window.open('<%=basePath%>grid/toNewGrid?fid='+id); 
}
$("#checkall").click(function(){ 
  $("input[name='id']").each(function(){
	  if (this.checked) {
		  this.checked = false;
	  }
	  else {
		  this.checked = true;
	  }
  });
})

function DelSelect(){
	var Checkbox=false;
	 $("input[name='id']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认要删除选中的内容吗？");
		if (t==false) return false; 		
	}
	else{
		alert("请选择您要删除的内容!");
		return false;
	}
}

</script>
</body></html>